import { createRouter, createWebHistory } from "vue-router";
import Login from "@/views/Login.vue";
import Home from "@/views/Home.vue";
import TroubleShootingPage from "@/views/trouble_shooting/TroubleShootingPage.vue";
import StartModelService from "@/components/pop_up/StartModelService.vue";
import FullControlPanel from "@/components/pop_up/FullControlPanel.vue";
import MultimeterTestPage from "@/views/MultimeterTestPage.vue";
import { principleRoutes } from "./principle";
import { setupRouterGuard } from "./guard";

const routes = [
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
  },
  {
    path: "/trouble-shooting",
    name: "TroubleShooting",
    component: TroubleShootingPage,
    meta: {
      requiresAuth: true,
    },
  },
  {
    path: "/start-model",
    name: "StartModel",
    component: StartModelService,
    meta: {
      requiresAuth: true,
    },
  },
  {
    path: "/full-control",
    name: "FullControl",
    component: FullControlPanel,
    meta: {
      requiresAuth: true,
    },
  },
  {
    path: "/multimeter",
    name: "MultimeterTest",
    component: MultimeterTestPage,
    meta: {
      requiresAuth: true,
    },
  },
  ...principleRoutes,
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

// 设置路由守卫
setupRouterGuard(router);

export default router;
